package com.ikkong.biz.meta.intercept;

import com.ikkong.biz.model.Teacher;
import com.ikkong.core.aop.AopContext;
import com.ikkong.core.constant.ConstShiro;
import com.ikkong.core.exception.BizException;
import com.ikkong.core.jfinal.ext.shiro.ShiroKit;
import com.ikkong.core.meta.PageIntercept;

public class FlowIntercept extends PageIntercept {

	@Override
	public void queryBefore(AopContext ac) {
		if (ShiroKit.lacksRole(ConstShiro.ADMINISTRATOR)) {
			//TODO 
			Teacher t = ShiroKit.getTeacher();
			if(null == t){
				throw new BizException(ConstShiro.NO_TEACHER);
			}
			String condition = " and cuser = "+t.getId();
			ac.setCondition(condition);
		}
	}

}
